import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";

const routes = [
  {
    path: "/",
    name: "home",
    component: HomeView,
    children: [
      {
        path: "rules",
        component: () =>
          import(/* webpackChunkName: "home" */ "../views/RulesView"),
      },
    ],
  },
  {
    path: "/countdown",
    name: "countdown",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "countdown" */ "../views/CountdownView"),
  },
  {
    path: "/quiz",
    name: "quiz",
    component: () => import(/* webpackChunkName: "quiz" */ "../views/QuizView"),
  },
  // {
  //   path: "/about",
  //   name: "about",
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () =>
  //     import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
  // },
  {
    path: "/read",
    name: "read",
    component: () => import(/* webpackChunkName: "read" */ "../views/ReadView"),
  },
  {
    path: "/rank",
    name: "rank",
    component: () => import(/* webpackChunkName: "rank" */ "../views/RankView"),
  },
  {
    path: "/certificate",
    name: "certificate",
    component: () =>
      import(/* webpackChunckName: "rank" */ "../views/CertificateView"),
  },
  {
    path: "/404",
    name: "NotFound",
    component: () =>
      import(/* webpackChunkName: "any" */ "../views/NotFoundView"),
  },
  {
    path: "/:catchAll(.*)",
    redirect: "/404",
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
